home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
mhs_c.arc
/
OUTPOST.ARC
/
OUTPOST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-27
|
5KB
|
207 lines
/* (C) Copyright 1987,1988 - TaxWare/Neil W. Taylor */
#include "cctypes.h"
/* #define WORKSPACE 2000 */
/* ****************** GLOBAL VARIABLES ****************** */
int ErrorsInThisFile = 0;
int WarningsInThisFile = 0;
int warningFound;
int contentsWritten = 0;
int comType;
int InFile;
int OutFile;
char InFileName[256];
char OutFileName[256];
char workArea[64]; /* argv[4] */
char messageBuffer[MESSAGE_SIZE];
FILEINFO fileInfo;
XRB XRBRec[24];
int lineNumber = 0, lNumber = 0;
/* char Out[WORKSPACE]; */
/* char originatingHost[37]; */
long fileSize = 0;
char InExtension[] = ".XRB";
char OutExtension[] = ".CCM";
char *CommandTypes[] = {
"",
"Date:",
"From:",
"To:",
"Message-id:",
"Conversation-id:",
"Via-host:",
"Subject:",
"Message-type:",
"Copies-to:",
"Re-sent-by:",
"Respond-by:",
"Possibility:",
"Action:",
"Ret-Message:",
"In-reply-to:",
"Form:",
"Domain:",
"Complete-by:",
"New-complete-by:",
"Attachment-name:",
"Net-attachment:",
0
};
char *ErrorTypes[] = {
"Unknown Error",
"Syntax",
"Cannot Open File",
"Cannot Create Output",
};
void UpperCase();
int Parse();
extern int OpenInputFile();
extern int OpenOutputFile();
int GetCommandType();
int GetParameter();
int SetUpOutFile();
void FinishUpOutFile();
void Error();
void Warning();
int MergeIt();
/* void InitMCB(); */
/* extern int FindFirstFile();
extern int FindNextFile(); */
void WriteLine();
void main(argc, argv)
int argc;
char *argv[];
{
int exitCode = ERROR_ENCOUNTERED, ccode, pause = 0, totalMsgs = 0, i;
char commandLine[256], command[80], *p, searchAttributes;
system("CLS");
for ( i = 1; i < 6; i++ )
WriteLine("\0");
WriteLine(" MHS / cc:Mail Gateway\0");
WriteLine("\0");
WriteLine(" Converting message(s) to cc: format...\0");
WriteLine("\0");
if (argc != 7 ) goto Out;
/* *************** OUTPOST ALGORITHM **************** */
/* MAP Q: to argv[5] (gateway host area) */
/* MAP P: to argv[4] (gateway host mailbag/database area) */
/* FindFirstFile(filePath, fileInfo, searchAttributes); */
Repeat:
/* get next SMF file from Q:OUT (and open for reading, if parsing */
/* directly to CC:MAIL format) */
/* (if the SMF file got this far, we know that it is destined for CC:MAIL */
/* XRBOXOUT the current SMF file to a temp file .XRB in the host's */
/* mail area (P:) */
/* convert the .XRB file to CC:MAIL format and... */
/* IMPORT that file into CC:MAIL's database */
/* if the IMPORT is successful, unlink the $T file (what about any attachments ?) */
/* FindNextFile(fileInfo); */
/* goto Repeat */
strcpy(workArea, argv[4]);
sprintf(commandLine, "MAP Q:=%s > NUL:", argv[5]);
system(commandLine);
sprintf(commandLine, "MAP P:=%s > NUL:", workArea);
system(commandLine);
searchAttributes = (char)0;
/* filename is $T*. under NetWare and *. under DOS */
sprintf(command, "Q:OUT\\*.");
ccode = FindFirstFile(command, &fileInfo, searchAttributes);
while ( !ccode ) {
messageBuffer[0] = '\0';
contentsWritten = 0;
/* *******XRBOXOUT********* */
sprintf(commandLine, "XRBOXOUT Q:OUT\\%s >P:CCMAIL.XRB", fileInfo.fileName);
ccode = system(commandLine);
if ( ccode ) continue;
/* ******* Get Ready To Read The Newly Created .XRB File */
sprintf(InFileName, "P:CCMAIL.XRB");
ccode = OpenInputFile();
if ( ccode ) {
Error(CANNOT_OPEN_FILE);
goto Out;
}
/* ********* SETUP .CCM FILE ******** */
if ( SetUpOutFile() ) {
Error(CANNOT_CREATE_OUTPUT);
goto Out;
}
/* ******* PARSE ******* */
/* PARSE the temporary file created by the XRBOXOUT utility */
ccode = Parse();
ccode = WriteCCMFileMsg();
/* exec CC:MAIL's IMPORT utility */
if ( !pause ) {
WriteLine("\0");
WriteLine(" Importing message(s) to cc:Mail...\0");
pause++;
}
sprintf(commandLine,"IMPORT %s %s P: @P:CCMAIL.CCM >NUL:",argv[1],argv[3]);
ccode = system(commandLine);
if ( !ccode ) {
/* delete the SMF and temp files */
totalMsgs++;
unlink("P:CCMAIL.XRB");
sprintf(command, "Q:OUT\\%s", fileInfo.fileName);
unlink(command);
/* ...what about attachment files ??? STUB */
}
exitCode = NO_ERROR; /* ?? */
ccode = FindNextFile(&fileInfo);
} /* end while */
sprintf(command, " %d message(s) imported.", totalMsgs);
WriteLine(command);
WriteLine("\0");
Out:
close(InFile);
system("CLS");
exit(exitCode);
}
void WriteLine(string)
char *string;
{
/* char line[80], temp[79];
strncpy(temp, " ",
76-strlen(string));
sprintf(line, "│%s%s\n", string, temp);
printf(line); */
printf("%s\n",string);
}